package com.fjec.common.ys.protocol;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class ResSearchReg extends HashMap<String, Object> {

    private final static String DATA_KEY = "ysepay_merchant_register_query_response";
    private final static String USER_CODE = "usercode";
    private final static String CUST_NAME = "custname";
    private final static String CUST_ID = "custid";
    private final static String USER_STATUS = "user_status";
    private final static String CREATE_TIME = "createtime";
    private final static String CUST_STATUS = "cust_status";
    private final static String IS_NEED_CONTRACT = "is_need_contract";
    private final static String MERCHANT_NO = "merchant_no";
    private final static String NOTE = "note";

    public String getSign() {
        return MapUtils.getString(this, YsConst.SIGN_KEY);
    }

    public Map<String, Object> getData() {
        return MapUtils.getMap(this, DATA_KEY, new HashMap<String, Object>());
    }

    public int getCode() {
        return MapUtils.getIntValue(getData(), YsConst.CODE_KEY, 0);
    }

    public String getMsg() {
        return MapUtils.getString(getData(), YsConst.MSG_KEY);
    }

    public String getSubCode() {
        return MapUtils.getString(getData(), YsConst.SUB_CODE_KEY);
    }

    public String getSubMsg() {
        return MapUtils.getString(getData(), YsConst.SUB_MSG_KEY);
    }

    public String getUserCode() {
        return MapUtils.getString(getData(), USER_CODE);
    }

    public String getCustName() {
        return MapUtils.getString(getData(), CUST_NAME);
    }

    public String getCustId() {
        return MapUtils.getString(getData(), CUST_ID);
    }

    public String getUserStatus() {
        return MapUtils.getString(getData(), USER_STATUS);
    }

    public String getCreateTime() {
        return MapUtils.getString(getData(), CREATE_TIME);
    }

    public String getCustStatus() {
        return MapUtils.getString(getData(), CUST_STATUS);
    }

    public boolean isNeedContract() {
        String isNeedContract = MapUtils.getString(getData(), IS_NEED_CONTRACT);
        return StringUtils.equals(isNeedContract, "Y");
    }

    public Long getMerchantNo() {
        return MapUtils.getLong(getData(), MERCHANT_NO);
    }

    public String getNote() {
        return MapUtils.getString(getData(), NOTE);
    }

}
